/*
 * Copyright 2008-2012 Centro Andaluz de Innovación y Tecnologías de la
 * Información y las Comunicaciones (CITIC). All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
 *
 * Please contact CITIC - Edificio CITIC, C/ Marie Curie, 6 Parque
 * Tecnológico de Andalucía 29590 - Campanillas, Málaga, Spain
 * or visit www.citic.es, if you need additional information or
 * have any questions.
 */

package es.citic.puedes.youtube.testhelp;

import java.util.ArrayList;
import java.util.List;

import es.citic.puedes.youtube.IYouTubeManager;
import es.citic.puedes.youtube.YouTubeAuthException;
import es.citic.puedes.youtube.YouTubeException;
import es.citic.puedes.youtube.model.UserPreferences;
import es.citic.puedes.youtube.test.YouTubeManagerTest;

public class YouTubePreferencesTest {

	public static void runYouTubeSetPreferencesTest(IYouTubeManager ytm, Integer userId) throws SecurityException, YouTubeException, YouTubeAuthException {
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}

		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		keywords.add("waka waka");
		keywords.add("worldcup");
		keywords.add("africa");

		// test for updating the visit counts in the preferences			
		ytm.setPreferences(userId, keywords);
	}

	public static void runYouTubeMarkPreferencesTest(IYouTubeManager ytm, Integer userId) throws SecurityException, YouTubeException, YouTubeAuthException {		
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}

		List<String> keywords = new ArrayList<String>();
		keywords.add("shakira");
		keywords.add("waka waka");
		keywords.add("worldcup");
		keywords.add("africa");

		// test for updating like or dislike counts in the preferences
		boolean hasLiked = true;
		ytm.setMarkPreferences(userId, keywords, hasLiked);
	}

	public static void runYouTubeGetPreferencesTest(IYouTubeManager ytm, Integer userId) throws SecurityException, YouTubeException, YouTubeAuthException {
		try {
			ytm.registreUser(userId, YouTubeManagerTest.username, YouTubeManagerTest.pass);
		} catch (Exception e) {
			// Nothing to do
		}
		try {
			List<String> keywords = new ArrayList<String>();
			keywords.add("shakira");
			keywords.add("waka waka");
			keywords.add("worldcup");
			keywords.add("africa");

			// test for updating the visit counts in the preferences			
			ytm.setPreferences(userId, keywords);
		} catch (Exception e) {
			// Nothing to do
		}

		// test for getting the preferences from an user
		UserPreferences userPreferences = ytm.getPreferences(userId);
		YouTubePrinterTestMethods.printPreferences(userPreferences);
	}
}
